﻿<Window x:Class="SanctusSoftware.CcliSongSelectLib.Wpf.SongSelectSearchWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:SanctusSoftware.CcliSongSelectLib.Wpf"
    Title="SongSelect Search" 
    Height="600" Width="800" >
    <Window.Resources>
        <ResourceDictionary>
            <Style TargetType="{x:Type Button}">
                <Setter Property="Width" Value="75" />
            </Style>
            <local:InverseBooleanConverter x:Key="inverseBooleanConverter" />
        </ResourceDictionary>
    </Window.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Border 
            Grid.Column="0" Grid.Row="0"
            Padding="10"
            Background="SkyBlue">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <StackPanel Grid.Row="0">
                    <StackPanel.Resources>
                        <Style TargetType="{x:Type TextBox}">
                            <Setter Property="BorderThickness" Value="0.5" />
                            <Setter Property="BorderBrush" Value="Black" />
                            <Setter Property="MinWidth" Value="150" />
                        </Style>
                    </StackPanel.Resources>
                    <Label Margin="0 10 0 0">Title</Label>
                    <TextBox 
                        Text="{Binding SearchTitle, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                        TextChanged="SearchCriterion_TextChanged" />
                    <Label Margin="0 10 0 0">Theme</Label>
                    <TextBox 
                        Text="{Binding SearchTheme, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                        TextChanged="SearchCriterion_TextChanged" />
                    <Label Margin="0 10 0 0">Author</Label>
                    <TextBox 
                        Text="{Binding SearchAuthor, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                        TextChanged="SearchCriterion_TextChanged" />
                    <Label Margin="0 10 0 0">Words</Label>
                    <TextBox 
                        Text="{Binding SearchWords, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                        TextChanged="SearchCriterion_TextChanged" />
                </StackPanel>
                <CheckBox 
                    Grid.Row="1"
                    Margin="0 0 0 10"
                    x:Name="_SearchAsITypeCheckBox">Search As I Type</CheckBox>
                <Button 
                    Grid.Row="2" 
                    x:Name="_SearchButton"
                    IsEnabled="{Binding ElementName=_SearchAsITypeCheckBox, Path=IsChecked, Converter={StaticResource inverseBooleanConverter}}"
                    HorizontalAlignment="Right" Click="_SearchButton_Click">Search</Button>
            </Grid>
        </Border>
        <DataGrid 
            Grid.Column="1" Grid.Row="0"
            AutoGenerateColumns="False" 
            ItemsSource="{Binding FoundDocuments}"
            CanUserAddRows="False"
            CanUserDeleteRows="False"
            CanUserReorderColumns="True"
            CanUserResizeColumns="True"
            CanUserResizeRows="False"
            GridLinesVisibility="None"
            Name="dataGrid1">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Title" Binding="{Binding Title, Mode=OneWay}" />
                <DataGridTextColumn Header="Authors" Binding="{Binding AuthorFormatted, Mode=OneWay}" />
                <DataGridTextColumn Header="Themes" Binding="{Binding ThemesFormatted, Mode=OneWay}" />
                <DataGridTextColumn Header="Keys" Binding="{Binding Keys, Mode=OneWay}" />
                <DataGridTextColumn Header="CCLI Number" Binding="{Binding CcliNumber, Mode=OneWay}" />
                <DataGridTextColumn Header="Copyright" Binding="{Binding CopyrightFormatted, Mode=OneWay}" />
                <DataGridTextColumn Header="Admin" Binding="{Binding AdminFormatted, Mode=OneWay}" />
            </DataGrid.Columns>
        </DataGrid>
        <StackPanel 
            Grid.Column="1" Grid.Row="1"
            Margin="0 5 0 5"
            Orientation="Horizontal"
            HorizontalAlignment="Right">
            <Button x:Name="_OKButton" Margin="0 0 10 0" Click="_OKButton_Click">OK</Button>
            <Button x:Name="_CancelButton" Margin="0 0 10 0" Click="_CancelButton_Click">Cancel</Button>
        </StackPanel>
    </Grid>
</Window>
